unit threads;

interface

implementation

var
 threadvarblocksize: longint = 0;
 omgbuffer: array[0..16*1024] of byte;

procedure SysInitThreadvar(var offset : dword;size : dword);
begin
   offset:=threadvarblocksize;
   inc(threadvarblocksize,size);
end;

procedure SysAllocateThreadVars;
begin
   
end;

function SysRelocateThreadvar(offset : dword) : pointer;
begin

end;

procedure SysReleaseThreadVars;
begin

end;

{*****************************************************************************
                            Thread starting
*****************************************************************************}

function SysBeginThread(sa : Pointer;stacksize : ptruint; ThreadFunction : tthreadfunc;p : pointer; creationFlags : dword;var ThreadId : TThreadID) : TThreadID;
begin
	result := InvalidHandle;
	
	
end;

procedure SysEndThread(ExitCode : DWord);
begin
	DestroyThread(GetCurrentThreadHandle());
end;

procedure SysThreadSwitch;
begin
end;

function  SysSuspendThread (threadHandle : TThreadID) : dword;
begin
	result := System.SleepThread(ThreadHandle);
end;

function  SysResumeThread  (threadHandle : TThreadID) : dword;
begin
	result := System.WakeupThread(ThreadHandle);
end;

function  SysKillThread (threadHandle : TThreadID) : dword;
begin
	result := DestroyThread(ThreadHandle);
end;

function  SysWaitForThreadTerminate (threadHandle : TThreadID; TimeoutMs : longint) : dword;
begin
	result := 0;
end;

function  SysThreadSetPriority (threadHandle : TThreadID; Prio: longint): boolean;            {-15..+15, 0=normal}
begin
	result := false;
end;

function  SysThreadGetPriority (threadHandle : TThreadID): longint;
begin
	result := 0;
end;

function  SysGetCurrentThreadId : TThreadID;
begin
	result := GetCurrentThreadHandle;
end;

{*****************************************************************************
                          Delphi/Win32 compatibility
*****************************************************************************}

procedure SySInitCriticalSection(var cs);
begin

end;

procedure SysDoneCriticalSection(var cs);
begin

end;

procedure SysEnterCriticalSection(var cs);
begin

end;

procedure SySLeaveCriticalSection(var cs);
begin

end;

{*****************************************************************************
                          Events
*****************************************************************************}

function sysBasicEventCreate(EventAttributes : Pointer; AManualReset,InitialState : Boolean;const Name : ansistring):pEventState;
begin

end;

procedure sysbasiceventdestroy(state:peventstate);
begin

end;

procedure sysbasiceventResetEvent(state:peventstate);
begin

end;

procedure sysbasiceventSetEvent(state:peventstate);
begin

end;

function sysbasiceventWaitFor(Timeout : Cardinal;state:peventstate) : longint;
begin

end;

function sysRTLEventCreate: PRTLEvent;
begin

end;

procedure sysRTLEventDestroy(AEvent: PRTLEvent);
begin

end;

procedure sysRTLEventSetEvent(AEvent: PRTLEvent);
begin

end;

procedure sysRTLEventResetEvent(AEvent: PRTLEvent);
begin

end;

procedure sysRTLEventWaitFor(AEvent: PRTLEvent);
begin

end;

procedure sysRTLEventWaitForTimeout(AEvent: PRTLEvent;timeout : longint);
begin

end;

Var
  WinThreadManager : TThreadManager;

Procedure InitSystemThreads;
begin
  With WinThreadManager do
    begin
    InitManager            :=Nil;
    DoneManager            :=Nil;
    BeginThread            :=@SysBeginThread;
    EndThread              :=@SysEndThread;
    SuspendThread          :=@SysSuspendThread;
    ResumeThread           :=@SysResumeThread;
    KillThread             :=@SysKillThread;
    ThreadSwitch           :=@SysThreadSwitch;
    WaitForThreadTerminate :=@SysWaitForThreadTerminate;
    ThreadSetPriority      :=@SysThreadSetPriority;
    ThreadGetPriority      :=@SysThreadGetPriority;
    GetCurrentThreadId     :=@SysGetCurrentThreadId;
    InitCriticalSection    :=@SysInitCriticalSection;
    DoneCriticalSection    :=@SysDoneCriticalSection;
    EnterCriticalSection   :=@SysEnterCriticalSection;
    LeaveCriticalSection   :=@SysLeaveCriticalSection;
    InitThreadVar          :=@SysInitThreadVar;
    RelocateThreadVar      :=@SysRelocateThreadVar;
    AllocateThreadVars     :=@SysAllocateThreadVars;
    ReleaseThreadVars      :=@SysReleaseThreadVars;
    BasicEventCreate       :=@SysBasicEventCreate;
    BasicEventDestroy      :=@SysBasicEventDestroy;
    BasicEventResetEvent   :=@SysBasicEventResetEvent;
    BasicEventSetEvent     :=@SysBasicEventSetEvent;
    BasiceventWaitFor      :=@SysBasiceventWaitFor;
    RTLEventCreate         :=@SysRTLEventCreate;
    RTLEventDestroy        :=@SysRTLEventDestroy;
    RTLEventSetEvent       :=@SysRTLEventSetEvent;
    RTLEventResetEvent     :=@SysRTLEventResetEvent;
    RTLEventWaitFor        :=@SysRTLEventWaitFor;
    RTLEventWaitForTimeout :=@SysRTLEventWaitForTimeout;
    end;
  SetThreadManager(WinThreadManager);
  ThreadID := GetCurrentThreadID;
end;

initialization
	InitSystemThreads;

end.
